<template>
  <div class="test">
    <h1>我是测试传参的</h1>
    <div>{{name}}</div>
    <router-link to="/ecIndex" tag="p">
      <a>{{id}}</a>
    </router-link>

    <button id="home" @click="homeC">Home</button>
    <button id="posts" @click="postC">Posts</button>
    <component :is="currentView"></component>
  </div>
</template>
<script>
    import ecindex from './ec-index.vue'
    import ecfriend from './ec-friends.vue'
    export default{
      name:'test',
      data:function(){
        return {
          id:"",
          name:"",
          currentView: "home"
        }
      },
      components: {
        home:ecindex,
        posts: ecfriend,
      },
      created:function(){
        this.id=this.$route.query.bookId
        this.name=this.$route.query.name
      },
      mounted:function(){
        this.loadFun()
      },
      methods:{
        loadFun:function(){
          this.$http.get('/test').then(function(response){
//              console.log(response);
          })
        },
        homeC:function(){
            this.currentView = "home";
          },
        postC:function(){
          this.currentView = "posts";
        }
      }
    }
</script>
<style>
</style>
